<?php
namespace tjsd\view;

/**
 * This view container is just adapter to other containers. It allredy implements
 * aliasing of offsetGet() to get() etc. By implementing this class you may omit
 * implementing offset..() methods again.
 * 
 * @author Jakub Tesárek <info@tjsd.cz>
 * @copyright 2012
 * @version 1.0
 */
abstract class ViewContainerAdapter extends \tjsd\core\Object implements ViewContainer {

	/**
	 * {@inheritdoc}
	 * 
	 * @param string $key		identifier of item
	 * @return mixed				value stored in container or null if nothing found
	 */
	public abstract function get($key);
	
	/**
	 * {@inheritdoc}
	 * 
	 * @param string $key		identifier of item
	 * @param string $value		value to be stored
	 */
	public abstract function add($key, $value);
	
	/**
	 * {@inheritdoc}
	 * 
	 * @param string $key			identifier of item
	 */
	public abstract function remove($key);
	
	/**
	 * {@inheritdoc}
	 * 
	 * @param string $key			identifier of item
	 * @return bool					true if item was found
	 */
	public abstract function contain($key);
	
	/**
	 * Alias for {@link contain()}.
	 * 
	 * @see contain()
	 */
	public function offsetExists($key) {
		return $this->contain($key);
	}
	
	/**
	 * Alias for {@link get()}.
	 * 
	 * @see get()
	 */
	public function offsetGet($key) {
		return $this->get($key);
	}
	
	/**
	 * Alias for {@link add()}.
	 * 
	 * @see add()
	 */
	public function offsetSet($key, $value) {
		return $this->add($key, $value);
	}
	
	/**
	 * Alias for {@link remove()}.
	 * 
	 * @see remove()
	 */
	public function offsetUnset($key) {
		return $this->remove($key);
	}
}